﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using PhoneStore.Entity;

namespace PhoneStore.Presentation
{
    /// <summary>
    /// Interaction logic for Login.xaml
    /// </summary>
    public partial class Login : WindowBase
    {
        public Staff user{get;set;}
        public bool IsOK{get;set;}
        public Login()
        {
            InitializeComponent();
            
        }

        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            user = DAO.Single<Staff>
                (x => x.Username == txtTaiKhoan.Text && x.Password == pwbMatKhau.Password);
            if (user == null)
            {
                MessageBox.Show("Tài khoản hoặc mật khẩu bị sai");
            }
            else
            {
                IsOK = true;
                this.Close();
            }

        }

        private void btnExit_Click(object sender, RoutedEventArgs e)
        {
            IsOK = false;
            this.Close();
        }
    }
}
